/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package src.services.system;

/**
 *
 * @author jay
 */

import java.util.List;
import src.domain.system.Company;
import src.HibernateUtil;
import org.hibernate.Query;
import org.hibernate.Session;
import src.services.CRUEDService;

public class CompanyModel {
    
    Session session;
    private CRUEDService service;
    private Company company;

    public CompanyModel() {
        service = new CRUEDService();
    }
    
    public Company getCompany() {
        this.session = HibernateUtil.getSessionFactory().getCurrentSession();
	
        try {
            org.hibernate.Transaction tx = session.beginTransaction();
            Query q = session.createQuery ("from Company");
            company = (Company) q.uniqueResult();
            
            tx.commit();
            
        } catch (Exception e) {}
        
        return company;
                
    }

    public void setCompany(Company company) {
        this.company = company;
    }
        
    public List<Company> findAll() {
        return (List<Company>) service.findAll("Company", null);
    }

    public boolean saveData(Company data) {
        return service.saveData(data);
    }
    
    public boolean deleteData(Company data) {
        return service.deleteData(data);
    }
    
}
